function mainPageFetchCatlogs() {
    $.ajax({
        type: 'post',
        async: true,
        data: '',
        url: document.location.origin + '/api/getrootcatlog',
        dataType: 'text',
        error: function () {
            console.log("Ajax 发生错误！");
        },
        success: function (data) {
            var json = JSON.parse(data);

            if (json.result == 200) {
                var totalCount = json.data.length;
                var totalRow = Math.ceil(totalCount / 4);

                var tableHandle = $('#rank-table');;

                var curIndex = 0;
                for (var row = 0; row < totalRow; ++row) {
                    var rowHandle = tableHandle.append('<tr></tr>');
                    for (var col = 0; col < 4; ++col) {
                        var uri = '/toppage' + json.data[curIndex][1];
                        rowHandle.append('<td><a href=' + uri + '>' + json.data[curIndex++][0] + '排名前10</a></td>');
                        if (curIndex >= totalCount) break;
                    }
                }
            } else {

            }
        }
    });
}

$(document).ready(function() {
    mainPageFetchCatlogs();
});